asp.net MVC

The "RenderBody" method has not been called for layout page

The "RenderBody" method has not been called for layout page , someone asked me to explain?

Assign Layout page inside _ViewStart.cshtml in views folder.

@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}

If you missed the @RenderBody() inside _Layout.cshtml(Layout page) you will get above error. So you must include it.

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width" />
    <title>@ViewBag.Title</title>
    @Styles.Render("~/Content/css")
    @Scripts.Render("~/bundles/modernizr")
</head>
<body>
    @RenderBody()
    @Scripts.Render("~/bundles/jquery")
    @RenderSection("scripts", required: false)
</body>
</html>

Post your comments / questions